import { DataSource } from "typeorm";
import { User } from "./entity/user";
import {createClient} from "redis";

export const AppDataSource = new DataSource({
    type: "mysql",
    host: "localhost",
    port: 3306,
    username: "root",
    password: "root",
    database: "aiserver",
    entities: [User],
    synchronize: true,
})

export const redisClient = createClient({
    url: "redis://localhost:6379",
})
    
redisClient.connect();

redisClient.on("error", (err) => {
    console.error("Redis error:", err);
});

redisClient.on("connect", () => {
    console.log("Redis connected");
});

redisClient.on("end", () => {
    console.log("Redis disconnected");
});
